package com.samsung.svmc.moneymanager.adapter;

import java.util.List;

import com.samsung.svmc.moneymanager.object.TheLoaiTaiKhoan;

import android.R;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

public class TheLoaiTaiKhoanAdapter extends ArrayAdapter<TheLoaiTaiKhoan> {

	private Context context;
    private List<TheLoaiTaiKhoan> itemList;
    
	public TheLoaiTaiKhoanAdapter(Context context, int textViewResourceId,
			List<TheLoaiTaiKhoan> objects) {
		super(context, textViewResourceId, objects);
		this.context = context;
		this.itemList = objects;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		TextView label;
		if(convertView == null){
			label = new TextView(context);
			label.setTextColor(Color.BLACK);			
		}
		else{
			label = (TextView)convertView;
		}
		label.setText(itemList.get(position).getTenTheLoai());
		return label;
	}
	
	@Override
	public View getDropDownView(int position, View convertView, ViewGroup parent) {
		TextView tv;
		if(convertView == null){
		LayoutInflater inflater = LayoutInflater.from(context);
        convertView = inflater.inflate(
                com.samsung.svmc.moneymanager.R.layout.spinners_xml, parent, false);
        tv = (TextView) convertView
                .findViewById(com.samsung.svmc.moneymanager.R.id.txtItem);
        tv.setTextColor(Color.BLACK);
		}
		else
		{
			tv = (TextView) convertView
	                .findViewById(com.samsung.svmc.moneymanager.R.id.txtItem);
		}
        tv.setText(itemList.get(position).getTenTheLoai());        
        return convertView;
	}

}
